<template>
  <div class="app-container">
    <el-dialog title="审核记录" :close-on-click-modal="false" :visible.sync="visible" class="consignProd-add-upd" width="55%" @close="closeDialog">
      <!-- 列表相关区域 -->
      <el-table
        v-loading="pageLoading"
        :data="pageVO.list"
        max-height="500"
        border
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="寄售价格（元）" prop="price" align="center" width="130">
          <template slot-scope="{row}">
            <span>{{(row.price / 100).toFixed(2) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="审核方" prop="type" align="center" width="90">
          <template slot-scope="{row}">
            <el-tag v-if="row.type === 1" size="small">商户端</el-tag>
            <el-tag v-if="row.type === 2" size="small">平台端</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="审核人Id" prop="auditUser" align="center" width="90">
          <template slot-scope="{row}">
            <span>{{ row.auditUser }}</span>
          </template>
        </el-table-column>
        <el-table-column label="审核人" prop="userName" align="center" width="120">
          <template slot-scope="{row}">
            <span>{{ row.userName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="审核结果" prop="status" align="center" width="90">
          <template slot-scope="{row}">
            <el-tag v-if="row.status === 1" size="small">同意</el-tag>
            <el-tag v-if="row.status === 2" size="small" type="danger">驳回</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="审核原因" prop="auditReason" align="center">
          <template slot-scope="{row}">
            <span>{{ row.auditReason }}</span>
          </template>
        </el-table-column>
        <el-table-column label="审核时间" prop="createTime" align="center" width="160">
          <template slot-scope="{row}">
            <span>{{ row.createTime }}</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页条 -->
<!--      <pagination v-show="pageVO.total>0" :total="pageVO.total" :page.sync="pageQuery.pageNum" :limit.sync="pageQuery.pageSize" @pagination="getPage()" />-->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageQuery.pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageQuery.pageSize"
        :total="pageVO.total"
        layout="total, sizes, prev, pager, next, jumper"
      ></el-pagination>
    </el-dialog>
  </div>
</template>

<script>

  export default {
    name: '',
    components: { },
    data() {
      return {
        resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
        // 查询的参数
        pageQuery: {
          pageSize: 10,
          pageNum: 1
        },
        visible: false,
        // 返回参数
        dataVO: [],
        pageVO: {
          list: [], // 返回的列表
          total: 0, // 一共多少条数据
          pages: 0 // 一共多少页
        },
        prodConfig: {},
        // loading
        pageLoading: true,
        // 查询参数
        searchParam: {},
        autoAuditSwitch: false,
        ids: [],
        addOrUpdateVisible: false
      }
    },
    mounted() {
    },
    methods: {

      handleSizeChange (val) {
        this.pageQuery.pageSize = val
        this.getPage()
      },
      handleCurrentChange (val) {
        this.pageQuery.pageNum = val
        this.getPage()
      },
      init(consignId) {
        this.searchParam.consignId = consignId
        this.visible = true
        this.pageLoading = true
        this.$nextTick(() => {
          if (!consignId) {
            return
          }
          this.getPage()
        })
      },
      getPage() {
        this.pageLoading = true
        this.$http({
          url: this.$http.adornUrl('/admin/consign/audit/record/page'),
          method: 'get',
          params: this.$http.adornParams(
            Object.assign({ ...this.pageQuery, ...this.searchParam })
          )
        }).then(({data}) => {
          this.pageLoading = false
          this.pageVO.list = data.list
          this.pageVO.total = data.total
        })
      },
      closeDialog() {
        this.visible = false
        this.searchParam = {}
      }
    }
  }
</script>

<style lang="scss" scoped>
  .app-container {
    .brand-logo-img {
      width: auto;
      height: auto;
      max-width: 100%;
      max-height: 200px;
    }
  }
</style>
